package chapter13;

public class TestGeometricObject {
  /** Main method */
  public static void main(String[] args) {
    // Declare and initialize two geometric objects
    GeometricObject geoObject1 = new Circle(5);
    GeometricObject geoObject2 = new Rectangle(5, 3);
    GeometricObject geoObject3 = new Parallelogram(3,5,8);
    GeometricObject[] geoObjects = new GeometricObject[]{geoObject1,geoObject2,geoObject3};
//    System.out.println("The two objects have the same area? " +
//      equalArea(geoObject1, geoObject2));
//
//    // Display circle
//    displayGeometricObject(geoObject1);
//
//    // Display rectangle
//    displayGeometricObject(geoObject2);
    System.out.println("Max area is "+MaxArea(geoObjects));
    System.out.println("Min perimeter is "+MinPerimeter(geoObjects));

  }

  /** A method for comparing the areas of two geometric objects */
  public static boolean equalArea(GeometricObject object1,
      GeometricObject object2) {
    return object1.getArea() == object2.getArea();
  }

  /** A method for displaying a geometric object */
  public static void displayGeometricObject(GeometricObject object) {
    System.out.println();
    System.out.println("The area is " + object.getArea());
    System.out.println("The perimeter is " + object.getPerimeter());
  }
  public static double MaxArea(GeometricObject[] geoObjects){
    Double Max = geoObjects[0].getArea();
    for (int i = 0;i<geoObjects.length-1;i++ ){
      if (geoObjects[i].getArea()>geoObjects[i+1].getArea()){
        Max = geoObjects[i].getArea();
      }
    }
    return Max;
  }
  public static double MinPerimeter(GeometricObject[] geoObjects){
    Double Max = geoObjects[0].getArea();
    for (int i = 0;i<geoObjects.length-1;i++ ){
      if (geoObjects[i].getPerimeter()<geoObjects[i+1].getPerimeter()){
        Max = geoObjects[i].getPerimeter();
      }
    }
    return Max;
  }
}
